package com.aaa.service.impl;

import com.aaa.entity.Products;
import com.aaa.mapper.ProductsDao;
import com.aaa.service.ProductsService;
import com.aaa.util.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ fileName:ProductServiceImpl
 * @ description:
 * @ author:Azy
 * @ createTime:2023/4/9 12:44
 * @ version:1.0.0
 */
@Service
public class ProductServiceImpl implements ProductsService {
    @Resource
    private ProductsDao productsDao;
    @Override
    public Result queryById(String pid) {
        Products product=productsDao.queryById(pid);
        return new Result(200,"Query Success!",product);
    }

    @Override
    public Result queryAll() {
        List<Products> products = productsDao.queryAll();
        return new Result(200,"Query Success!",products);
    }

    @Override
    public Result deleteById(String pid) {
        Integer getId = productsDao.deleteById(pid);
        return new Result(200,"Delete Success!",getId);
    }

    @Override
    public Result insert(Products products) {
        Integer insert=productsDao.insert(products);
        return new Result(200,"Insert Success!",insert);
    }

    @Override
    public Result update(Products products ) {
        Integer update=productsDao.update(products);
        return new Result(200,"Update Success!",update);
    }
}
